import requests

url = 'https://www.baidu.com/?tn=78000241_12_hao_pg'
headers = {
    'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
}
# 在请求头中带上user-agent，模拟浏览器发送请求
# r = requests.get(url)
r = requests.get(url, headers=headers)
# 打印请求头信息
print(r.request.headers)
# 响应内容
print(r.text)